import request from '@/config/axios'

export interface EvalPersonnelAssignmentVO {
  id?: number
  planId: number
  userId: number
  personType: number
  assignmentRole?: string
  assignmentDate: string
  assignmentStatus: number
  assignmentComments?: string
  createTime?: Date
}

export interface EvalPersonnelAssignmentPageReqVO extends PageParam {
  planId?: number
  userId?: number
  personType?: number
  assignmentRole?: string
  assignmentStatus?: number
  assignmentDate?: string[]
  createTime?: Date[]
}

export interface EvalPersonnelAssignmentBatchReqVO {
  planId: number
  userIds: number[]
  personType: number
  assignmentRole?: string
  assignmentComments?: string
}

// 查询人员分配分页
export const getPersonnelAssignmentPage = (params: EvalPersonnelAssignmentPageReqVO) => {
  return request.get({ url: '/eval/personnel-assignment/page', params })
}

// 查询人员分配详情
export const getPersonnelAssignment = (id: number) => {
  return request.get({ url: '/eval/personnel-assignment/get?id=' + id })
}

// 新增人员分配
export const createPersonnelAssignment = (data: EvalPersonnelAssignmentVO) => {
  return request.post({ url: '/eval/personnel-assignment/create', data })
}

// 修改人员分配
export const updatePersonnelAssignment = (data: EvalPersonnelAssignmentVO) => {
  return request.put({ url: '/eval/personnel-assignment/update', data })
}

// 删除人员分配
export const deletePersonnelAssignment = (id: number) => {
  return request.delete({ url: '/eval/personnel-assignment/delete?id=' + id })
}

// 导出人员分配
export const exportPersonnelAssignment = (params: EvalPersonnelAssignmentPageReqVO) => {
  return request.download({ url: '/eval/personnel-assignment/export-excel', params })
}

// 根据计划ID获得人员分配列表
export const getPersonnelAssignmentListByPlanId = (planId: number) => {
  return request.get({ url: '/eval/personnel-assignment/list-by-plan?planId=' + planId })
}

// 根据人员类型获得人员分配列表
export const getPersonnelAssignmentListByPersonType = (personType: number) => {
  return request.get({ url: '/eval/personnel-assignment/list-by-person-type?personType=' + personType })
}

// 批量分配人员
export const batchAssignPersonnel = (data: EvalPersonnelAssignmentBatchReqVO) => {
  return request.post({ url: '/eval/personnel-assignment/batch-assign', data })
}

// 取消人员分配
export const cancelPersonnelAssignment = (id: number) => {
  return request.put({ url: '/eval/personnel-assignment/cancel?id=' + id })
}

// 确认人员分配
export const confirmPersonnelAssignment = (id: number) => {
  return request.put({ url: '/eval/personnel-assignment/confirm?id=' + id })
}

// 获取可分配人员列表
export const getAvailablePersonnelList = (planId: number, personType: number) => {
  return request.get({ url: `/eval/personnel-assignment/available-personnel?planId=${planId}&personType=${personType}` })
}
